import axios from "axios"
import {
  Toast
} from 'vant'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API
})

// axios 请求拦截
service.interceptors.request.use(function (config) {
  NProgress.start()
  return config
})

// 拦截响应
service.interceptors.response.use(response => {
  NProgress.done()
  return response
}, err => {
  Toast('网络请求失败...')
  Promise.reject(err)
})

export default service
